<template>
  <Card style="display: flex; justify-content: center;">
    <div style="display: flex; flex-direction: row; align-items: center;">
      商标：<Input v-model="trademark" placeholder="请输入商标" style="width: 600px; margin-left: 26px;" />
    </div>
    <div style="display: flex; flex-direction: row; align-items: center; margin-top: 20px;">
      缩写商标：<Input v-model="abbrTrademark" placeholder="请输入缩写商标" style="width: 600px;" />
    </div>
    <div style="display: flex; flex-direction: row; align-items: center; justify-content: center; margin-top: 20px;">
      <Button type="primary" @click="onSave">保存</Button>
    </div>
  </Card>
</template>

<script lang="ts">
import rcRequest from 'rc-request'
import jsCookie from 'js-cookie'

export default {
  name: 'agent-trademark-page',
  data() {
    return {
      // 公司id
      company_id: '',
      // 商标
      trademark: '',
      // 缩写商标
      abbrTrademark: '',
    };
  },
  methods: {
    // 保存
    async onSave() {
      if (this.trademark.length === 0) {
        this.$Message.error('商标不能为空');
        return;
      } else if (this.abbrTrademark.length === 0) {
        this.$Message.error('缩写商标不能为空');
        return;
      }

      await rcRequest({
        method: 'post',
        url: '/company/update_company_info',
        data: {
          company_id: this.company_id,
          trademark: this.trademark,
          abbreviated_trademark: this.abbrTrademark,
        },
      })

      this.$Message.success('保存成功');
    },
    // 获取信息
    async getDetail() {
      const { data: { data: [{ id, trademark, abbreviated_trademark }] } } = await rcRequest({
        method: 'post',
        url: '/company/select_user_company_info',
        data: { },
      })
      this.company_id = id;
      this.trademark = trademark;
      this.abbrTrademark = abbreviated_trademark;
    },
  },
  mounted() {
    this.getDetail()
  },
}
</script>
